#include "display.h"

NX_PRIVATE WM_Display wm_display;

NX_Error WM_DisplayPresent(NX_Surface * surface, NX_Region *region)
{
    NX_SurfaceBlitRegion(&wm_display.surface, surface, *region, *region);
    WM_DisplayFrameBufferPresent();
    return NX_EOK;
}

NX_U32 WM_DisplayGetWidth(void)
{
    return wm_display.surface.width;
}

NX_U32 WM_DisplayGetHeight(void)
{
    return wm_display.surface.height;
}

NX_Addr WM_DisplayGetPhyBase(void)
{
    return wm_display.phyBaseAddr;
}

void WM_DisplaySetPhyBase(NX_Addr addr)
{
    wm_display.phyBaseAddr = addr;
}

NX_Surface *WM_DisplayGetSurface(void)
{
    return &wm_display.surface;
}

NX_Error WM_DisplayInit(void)
{
    NX_Error err;
    
    if ((err = WM_DisplayFrameBufferInit()) != NX_EOK)
    {
        return err;
    }
    
    return NX_EOK;
}

NX_Error WM_DisplayExit(void)
{
    WM_DisplayFrameBufferExit();
    return NX_EOK;
}
